//
//  CGQMessageTableViewCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/5/11.
//  Copyright © 2021 叁拾叁. All rights reserved.
//


import UIKit


class CGQMessageTableViewCell: SYBaseCell {

    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 17.autoBoldFontSize()
        v.text = "设备离线"
        return v
    }()
    
    let subTitle: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 14.autoFontSize()
        v.numberOfLines = 0
        v.text = "蝴蝶兰-北展厅温湿度设备已离线，请立即..."
        v.isHidden = true
        return v
    }()
    
    let time: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 12.autoFontSize()
        v.text = "3月10日"
        v.isHidden = true
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        v.sy_name("im_icon")
        return v
    }()
    
    let arrow: UIImageView = {
        let v: UIImageView = UIImageView()
        v.sy_name("arrow_gray")
        return v
    }()
    

    
    
    
    public func configureMessageView(model:NSMessageDataListModel){
        
        title.text = model.name ?? "暂无"
    
//        time.text = model.time
//        subTitle.text = model.msg
        
        if model.type == "1" {
            
            pic.sy_name("shebei_lixian_icon");
            
        }
        else if model.type == "2" {
            
            pic.sy_name("shebei_yujing_icon");
            
        }
        else if model.type == "3" {
            
            pic.sy_name("port_off_ico");

        }
        else if model.type == "4" {
            pic.sy_name("port_open_ico");

            
            
        }
        
        
        
    }
    override func initViews() {
        
        self.backgroundColor = .white
        addSubview(pic)
        addSubview(title)
        addSubview(subTitle)
        addSubview(arrow)
        addSubview(time)
        addSubview(lineView)
        
        pic.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(22.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(10))
            make.width.equalTo(33.autoWidth())
            make.height.equalTo(33.0.autoWidth())
            make.bottom.equalToSuperview().offset(-28.autoWidth())
        }
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(20.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(53))
            make.right.equalToSuperview().offset(autoWidth(-12.0))
            make.bottom.equalToSuperview().offset(-20.autoWidth())
//            make.height.equalTo(17.autoWidth())
        }
        subTitle.snp.makeConstraints { (make) in
//            make.bottom.equalToSuperview().offset(autoWidth(-20.0))
//            make.left.equalToSuperview().offset(autoWidth(53))
//            make.top.equalTo(title.snp.bottom).offset(autoWidth(14))
//            make.right.equalToSuperview().offset(autoWidth(-40))
//            make.height.equalTo(15.autoWidth())
        }
        arrow.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.width.equalTo(8.autoWidth())
            make.height.equalTo(14.autoWidth())
        }
        time.snp.makeConstraints { (make) in
            make.centerY.equalTo(title)
            make.right.equalToSuperview().offset(autoWidth(-13.0))
            make.height.equalTo(10.autoWidth())
        }
        
        lineView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(autoWidth(53))
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.height.equalTo(0.5.autoWidth())
            make.bottom.equalToSuperview()
        }
    }
}


